/*
 ============================================================================
 Name		: TradeBlockWithdrawal.h
 Author	  : Zhang Jiawei
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CTradeBlockWithdrawal declaration
 ============================================================================
 */

#ifndef TRADEBLOCKWITHDRAWAL_H
#define TRADEBLOCKWITHDRAWAL_H

// INCLUDES
#include "TradeBlock.h"
#include "TableWidget.h"
#include "Control.h"
#include "TradeBlockNetwork.h"

// CLASS DECLARATION

class CTradeBlockWithdrawal: public CTradeBlock, public MWidgetObserver, public MPushButtonObserver//, public MReqObserver
{
public:
    ~CTradeBlockWithdrawal();

    static CTradeBlockWithdrawal* NewL(CBaseBlock* bsBack = NULL);

    static CTradeBlockWithdrawal* NewLC(CBaseBlock* bsBack);

private:
    CTradeBlockWithdrawal(CBaseBlock* bsBack);

    void ConstructL();

public:
    void OnDraw(CFbsBitGc& g) const;

    void OnKeyDown(TInt keyCode);
    
    void OnMouseDown(const TPoint& aPt);
    
    void OnMouseMove(const TPoint& aPt);

    void OnMouseUp(const TPoint& aPt);

    void SizeChanged(); 
    
    void ChangeFocus(TBool aFoucs, const TInt& keyCode);
    
    void BeforeBack();
    
public: //MPushButtonObserver
    void PushButtonClicked();
    
public:
	TBool ProcessTradeNetworkMsg(TInt nError, TAny* p, const TDesC8& aBodyData);
	//TBool UpdateTradeNetwork(TInt nProgress);
	
public:
    // from MWidgetObserver
    void UpdateScreen();    
    void SelectOneRow(TInt aRowIndex);
    void LoseFocus(const TInt& keycode);

protected:
    void AddTabs();

    void BeforeDraw(CFbsBitGc& g) const;
    
private:
    void CreateTable();
    void CreateControls();
	void LayoutControls();
	
	void InitNetworkData();
    TBool AppendNetworkData(__sOrder_info_t* p_sOrderArray);
    void SetControlFocus(TBool bFocus, TInt nControlIndex);
    
private:
	enum TNetworkStatus
	{
		ENetworkStatus_None,
		ENetworkStatus_ReqQuery,
		ENetworkStatus_ReqSingle,
		ENetworkStatus_ReqMore,
		ENetworkStatus_Resp
	};
    
private:
    CTableWidget* 	iTable;
    
    //CPushButton*	iButtonWidthdrawal;
    CPushButton*	iButtonMore1;
    CPushButton*	iButtonMore2;
    
    TInt			iNetworkStatus;
	TInt			iNumberOfElement;
	TBool			iCanReq;
	TInt			iFocusControl;
	
	RArray<TInt>	iArray;
};

#endif // TRADEBLOCKWITHDRAWAL_H

